import request from '@/request/request'
import requestMock from '@/request/request'

//请求一级分类
export  const reqCategory1List =()=>{
 return request.get("/admin/product/getCategory1")
}
        // 请求二级分类
        export  const reqCategory2List=(category1Id)=>{
            return request.get(`/admin/product/getCategory2/${category1Id}`)
           }
           //请求三级分类
       //3. 请求3级分类
export const reqCategory3List = (category2Id) => {
    return request.get(`/admin/product/getCategory3/${category2Id}`);
  };
  export const reqBannerList = () => {
    return requestMock.get(`/mock-api/banner`);
  };


export const reqFloorList=()=>{
    return requestMock.get(`/mock-api/floor`)
}


//5. 请求搜索页数据
export const reqSearchList = (searchParams) => {
  return request.post(`/api/list`, searchParams);
};

//6. 请求详情页数据
export const reqDetailList = (skuId) => {
  return request.get(`/api/item/${skuId}`);
};

//7. 添加购物车或者修改购物车数量
export const reqAddOrUpdateCart = (skuId, skuNum) => {
  return request.post(`/api/cart/addToCart/${skuId}/${skuNum}`);
};

//8. 请求购物车列表
export const reqCartList = () => {
  return request.get(`/api/cart/cartList`);
};

//9. 切换单个商品的选中状态
export const reqCartSingleChange = (skuID, isChecked) => {
  return request.get(`/api/cart/checkCart/${skuID}/${isChecked}`);
};

//10. 切换全部商品的选中状态
export const reqCartAllChange = (isChecked, skuIdList) => {
  return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};

//11. 删除单个商品
export const reqCartSingleDelete = (skuId) => {
  return request.delete(`/api/cart/deleteCart/${skuId}`);
};

//12. 删除所有选中的商品
export const reqCartAllDelete = (skuIdList) => {
  return request.post(`/api/cart/batchDeleteCart`, skuIdList);
};
//注册获取验证码接口
export const reqUserCode=(phone)=>{
  return request.get(`/api/user/passport/sendCode/${phone}`)
}
//注册
export const reqRegister=(userInfo)=>{
  return request.post(`/api/user/passport/register`,userInfo)
}
//登录
export const reqLogin=(userInfo)=>{
  return request.post(`/api/user/passport/login`,userInfo)
}
//请求用户信息
export const reqUserMessage =()=>{
  return request.get(`/api/user/passport/auth/getUserInfo`)
}
//退出登录
export const reqLogout=()=>{
  return request.get(`/api/user/passport/logout`)
}
//获取交易页信息
export const reqTradeInfo=()=>{
  return request.get(`/api/order/auth/trade`)
}
//获取当前的收货地址
export const reqAddress=()=>{
  return requestMock.get(`/mock-api/address`)
}
//提交订单
export const reqAddOrder=(tradeNo,tradeDetil)=>{
  return request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`,tradeDetil)
}
//根据订单号获取支付详情
export const reqPayDetail=(orderId)=>{
  return request.get(`/api/payment/weixin/createNative/${orderId}`)
}
//查询当前的支付状态
export const reqPayStatus=(orderId)=>{
  return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`)
}
//查询我的订单分页数
export const reqMyOrder=(page,limit)=>{
  return request.get(`/api/order/auth/${page}/${limit}`)
}